package com.woniu108.carService.commos.util;


import com.alipay.api.AlipayClient;
import com.alipay.api.AlipayConfig;
import com.alipay.api.DefaultAlipayClient;
import lombok.Data;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@Data
//@Component
public class AlipayConfiguration {
    private String serverUrl="https://openapi-sandbox.dl.alipaydev.com/gateway.do";
    private String appid="9021000135692386";
    private String privateKey="MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCJzt0DDMriIYcZhClYc8n5vfSXCcjzjKRis6BkPXtumHWHXj5DQSQu0aSlNKb/BIO+hsQfcRusAWnRsCSLfbmBzqlw1r13KeD7a9/TWUyMhexUjdKljUhsG1lBSOraBSLbaEJBztMheIJvBpUplYLm3LQlDomnbqF6wVMctBg5Nw/s7pTt7xwZJjy2I1D103k5QKksstwiQBiCaF6uXXsl0MfnPuSLR2ajBRHvE/sQ8POTLwZE7ClS89xAHT9hToLaXMEQ8+W5TLJJb67XjOJ6AjUlj+HtIDd8pI0jpbfMQWtjGVCUYFLmwL/EwWxN9gS0FTS6UXebFm/6RkePo4iZAgMBAAECggEAWvaD5i58gNU2sv4MuIj9ie770vKvhSuRmmEM/v2iSvcxpN/tY0FNW+YfsrjVfkGBoLKeJE7pwBjSu4l0JesgFvHN4GCugUjQa8Th4kTwhVUlEQ7oO0TNyCYpPTGfa7e2MXNZQMz/iflcx2Jl9SPuWurVshwteqpIxplzfd/WmXSp/0gATf1nyA5DXIUZ2q95ReVTkAava5fn1a5DU0DNtcYo9m8yhJq2KLwDbI4FFFukCb3YZ+tTSd1JKaEARQVdWoh6JtU/1VHih1TYeaM/fVV8o6o/pkYs2jDOC6jKX7eoRbHCaVJsZgPA3p1TM8IzCAlVTJTAzxlqOr3xCrpBsQKBgQC+cWVIuYH8+31HDY7DgtgpTFw7YHj0yB2BVXb90KppljhwWAvtc231Ds4lLRhRl316jiFW22dwfQI9mL1eHWHBN+2oTch4dpMRE++vIaTVhMNXO5pb4K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14WzyM0giFY7L71ow5DxXAbIpRRIAd83a4dX+XGXDU6seL/sE4waKdyFeRv0NrCmbLAa1YwSscddvuxzP3nl7sQIDAQAB";

    @Bean
    public AlipayClient config() throws Exception {
        AlipayConfig alipayConfig = new AlipayConfig();
        //设置网关地址
        alipayConfig.setServerUrl(serverUrl);
        //设置应用ID
        alipayConfig.setAppId(appid);
        //设置应用私钥
        alipayConfig.setPrivateKey(privateKey);
        //设置支付宝公钥
        alipayConfig.setAlipayPublicKey(alipayPublicKey);
        //设置请求格式固定值json
        alipayConfig.setFormat("JSON");
        //设置字符集
        alipayConfig.setCharset("UTF-8");
        //设置签名类型
        alipayConfig.setSignType("RSA2");
        //实例化客户端
        AlipayClient alipayClient = new DefaultAlipayClient(alipayConfig);
        return alipayClient;
    }

}
